import os
import yaml
from conan import ConanFile
from conan.tools.files import copy

class openubmcsdkConan(ConanFile):
    name = "openubmcsdk"
    settings = "os", "compiler", "build_type", "arch"
    license = "Mulan PSL v2"
    description = "openubmc components SDK"
    no_copy_source = True


    def export(self):
        copy(self, "requirements.yml", dst=self.export_folder, src=self.recipe_folder)

    def requirements(self):
        requirements_path = os.path.join(self.recipe_folder, "requirements.yml")
        try:
            with open(requirements_path, 'r') as f:
                data = yaml.safe_load(f)
            for dependency in data['dependencies']:
                self.requires(dependency['conan'])
        except Exception as e:
            self.output.error(f"读取 requirements.yml 失败: {str(e)}")
            return
